package com.pro.service.imple;

import com.pro.mapper.JsMicroRecordMapper;
import com.pro.pojo.JsCourseRecord;
import com.pro.service.JsMicroRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * ClassName:JsMicroRecordServiceImple
 * Package:com.pro.service.imple
 * Description:
 *
 * @Date:2021/12/7 下午 4:17
 * @Author: WYH
 */
@Service
public class JsMicroRecordServiceImple implements JsMicroRecordService {

    @Autowired(required = false)
    private JsMicroRecordMapper jsMicroRecordMapper;

    @Override
    public List<JsCourseRecord> getAllMicRecord(String result) {
        List<JsCourseRecord> allMicRecord = jsMicroRecordMapper.getAllMicRecord(result);
        return allMicRecord;
    }

    @Override
    public Integer count(String result){
        Integer integer = jsMicroRecordMapper.count(result);
        return integer;
    };

    @Override
    public List<JsCourseRecord> getMoMicRecord(String artcleTitle, String artcleCategroyName, String trueName) {
        List<JsCourseRecord> moMicRecord = jsMicroRecordMapper.getMoMicRecord(artcleTitle, artcleCategroyName, trueName);
        return moMicRecord;
    }

    @Override
    public Integer countMo(String artcleTitle, String artcleCategroyName, String trueName) {
        Integer integer = jsMicroRecordMapper.countMo(artcleTitle, artcleCategroyName, trueName);
        return integer;
    }

    @Override
    public Boolean updateMicro(JsCourseRecord jsCourseRecord) {
        //时间类型转换成字符串
        SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
        String format = formatter.format(new Date());
        jsCourseRecord.setImplementDate(format);
        Boolean aBoolean = jsMicroRecordMapper.updateMicro(jsCourseRecord);
        return aBoolean;
    }
}
